﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;

namespace GetCpuInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            string info = "CPU当前频率为:\r\n";
            ManagementObjectSearcher MySearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
            foreach (ManagementObject MyObject in MySearcher.Get())
            {
                info += "\n" + String.Format("CurrentClockSpeed : " + MyObject["CurrentClockSpeed"].ToString());
                info += "\n=========================================================";
            }
            Console.WriteLine(info);

            info = "CPU的最大时钟频率是:\r\n";
            foreach (ManagementObject MyObject in MySearcher.Get())
            {
                info += "\n" + String.Format("MaxClockSpeed : " + MyObject["MaxClockSpeed"].ToString());
                info += "\n=========================================================";
            }
            Console.WriteLine(info);

            Console.ReadKey();
        }
    }
}
